package com.fc.remoting;

import java.util.concurrent.TimeUnit;

import com.fc.remoting.codec.RemotingMessageDecoder;
import com.fc.remoting.codec.RemotingMessageEncoder;
import com.fc.remoting.handler.ChannelManagerHandler;
import com.fc.remoting.handler.RemotingServerMessageHandler;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.timeout.ReadTimeoutHandler;

public class TcpChannelInitializer extends ChannelInitializer<SocketChannel>  {

	@Override
	protected void initChannel(SocketChannel ch) throws Exception {
		ch.pipeline().addLast(new ChannelManagerHandler());
		ch.pipeline().addLast(new RemotingMessageDecoder());
		ch.pipeline().addLast(new RemotingMessageEncoder());
		ch.pipeline().addLast(new ReadTimeoutHandler(5,TimeUnit.MINUTES));
		ch.pipeline().addLast(new RemotingServerMessageHandler());
	}
}
